class Page5 extends egret.DisplayObjectContainer{
	private bmp_bg:egret.Bitmap;
	private bmp_t0:egret.Bitmap;
	private bmp_t1:egret.Bitmap;
	private bmp_t2:egret.Bitmap;
	private bmp_t3:egret.Bitmap;
	private bmp_2017:egret.Bitmap;
	private bmp_tip1:egret.Bitmap;
	private bmp_tip2:egret.Bitmap;
	private sp_mask:egret.Shape;
	private mc:egret.MovieClip;
	private particle:particle.GravityParticleSystem;
	public constructor() {
		super();

		this.bmp_bg=new egret.Bitmap();
		this.bmp_bg.texture=RES.getRes('p5_bg_png');
		// this.bmp_bg.anchorOffsetX=this.bmp_bg.width/2;
		// this.bmp_bg.anchorOffsetY=this.bmp_bg.height/2;
		this.bmp_bg.x=0;
		this.bmp_bg.y=0;
		this.addChild(this.bmp_bg);

		this.bmp_t0=new egret.Bitmap();
		this.bmp_t0.texture=RES.getRes('p5_title0_png');
		this.bmp_t0.anchorOffsetX=this.bmp_t0.width/2;
		this.bmp_t0.anchorOffsetY=this.bmp_t0.height/2;
		this.bmp_t0.x=353;
		this.bmp_t0.y=227;
		this.bmp_t0.alpha=0;
		

		this.bmp_t1=new egret.Bitmap();
		this.bmp_t1.texture=RES.getRes('p5_title1_png');
		this.bmp_t1.anchorOffsetX=this.bmp_t1.width/2;
		this.bmp_t1.anchorOffsetY=this.bmp_t1.height/2;
		this.bmp_t1.x=370;
		// this.bmp_t1.y=740;
		this.bmp_t1.alpha=0;
		this.addChild(this.bmp_t1);

		this.bmp_t2=new egret.Bitmap();
		this.bmp_t2.texture=RES.getRes('p5_title2_png');
		this.bmp_t2.anchorOffsetX=this.bmp_t2.width/2;
		this.bmp_t2.anchorOffsetY=this.bmp_t2.height/2;
		this.bmp_t2.x=370;
		this.bmp_t2.y=855;
		this.bmp_t2.alpha=1;
		this.addChild(this.bmp_t2);

		this.sp_mask=new egret.Shape();
		this.sp_mask.graphics.beginFill(0,1);
		this.sp_mask.graphics.drawRect(0,0,603,258);
		this.sp_mask.graphics.endFill();
		this.sp_mask.anchorOffsetX=this.sp_mask.width/2;
		this.sp_mask.anchorOffsetY=this.sp_mask.height/2;
		this.sp_mask.x=370;
		this.sp_mask.y=859;
		this.addChild(this.sp_mask);
		this.sp_mask.scaleY=0;
		this.bmp_t2.mask=this.sp_mask;

		this.bmp_t3=new egret.Bitmap();
		this.bmp_t3.texture=RES.getRes('p5_title3_png');
		this.bmp_t3.anchorOffsetX=this.bmp_t3.width/2;
		this.bmp_t3.anchorOffsetY=this.bmp_t3.height/2;
		this.bmp_t3.x=370;
		// this.bmp_t3.y=947;
		this.bmp_t3.alpha=0;
		this.addChild(this.bmp_t3);

		this.particle = new particle.GravityParticleSystem(RES.getRes("leaf_png"), RES.getRes("leaf_json"));
		// this.particle.start();
		this.addChild(this.particle);
		console.log(this.particle);

		this.bmp_tip1=new egret.Bitmap();
		this.bmp_tip1.texture=RES.getRes('p1_tip1_png');
		this.bmp_tip1.anchorOffsetX=this.bmp_tip1.width/2;
		this.bmp_tip1.anchorOffsetY=this.bmp_tip1.height/2;
		this.bmp_tip1.x=370;
		this.bmp_tip1.y=1080;
		this.bmp_tip1.alpha=0.5;
		// this.addChild(this.bmp_tip1);
		egret.Tween.get(this.bmp_tip1,{loop:true}).to({y:1110,alpha:1},600,egret.Ease.cubicInOut).to({y:1080,alpha:0.5},600,egret.Ease.cubicInOut);

		this.bmp_tip2=new egret.Bitmap();
		this.bmp_tip2.texture=RES.getRes('p1_tip2_png');
		this.bmp_tip2.anchorOffsetX=this.bmp_tip2.width/2;
		this.bmp_tip2.anchorOffsetY=this.bmp_tip2.height/2;
		this.bmp_tip2.x=740/2;
		this.bmp_tip2.y=1075;
		this.bmp_tip2.alpha=0;
		this.addChild(this.bmp_tip2);
		// egret.Tween.get(this.bmp_tip2).to({y:1103,alpha:0.5},600,egret.Ease.cubicInOut).to({y:1120,alpha:1},600,egret.Ease.cubicInOut);

		this.mc = new egret.MovieClip( MovieClipData.mcFactory5.generateMovieClipData( "mc5" ));
		this.mc.frameRate=12;
		this.addChild(this.mc);
		this.mc.x=0;
		this.mc.y=0;
		this.mc.visible=false
		// this.mc3.gotoAndPlay(1,1)
		// this.mc3.addEventListener(egret.Event.COMPLETE,this.loopHandler,this);

		this.addChild(this.bmp_t0);

		this.addEventListener(egret.Event.ADDED_TO_STAGE,this.addToStage,this);
	}
	private addToStage(e:egret.Event):void
	{
		// this.bmp_t0.scaleX=this.bmp_t1.scaleY=0;
		
		
	}

	private t1:number;
	private t2:number;
	public In():void
	{
		this.removeTween();
		if(this.t1)
		{
			clearTimeout(this.t1);
		}
		if(this.t2)
		{
			clearTimeout(this.t2)
		}
		if(this.particle.visible)
		{
			this.particle.visible=false;
		}

		this.bmp_t0.y=227-50;
		this.bmp_t0.alpha=0;
		egret.Tween.get(this.bmp_t0).wait(1000).to({y:227,alpha:1},1000,egret.Ease.cubicInOut);

		this.bmp_t1.y=830;
		this.bmp_t1.alpha=0;
		egret.Tween.get(this.bmp_t1).wait(1000+700).to({y:696,alpha:1},1500,egret.Ease.cubicInOut);

		// this.bmp_t2.scaleX=this.bmp_t2.scaleY=1;
		// this.bmp_t2.alpha=0;
		// this.bmp_t2.y=854+30;
		// egret.Tween.get(this.bmp_t2).wait(1000+1400).to({y:854,scaleX:1,scaleY:1,alpha:1},1000,egret.Ease.cubicInOut);
		this.sp_mask.scaleY=0;
		egret.Tween.get(this.sp_mask).wait(1000+800).to({scaleY:1,alpha:1},1500);

		this.bmp_t3.y=860;
		this.bmp_t3.alpha=0;
		egret.Tween.get(this.bmp_t3).wait(1000+700).to({y:994,alpha:1},1500,egret.Ease.cubicInOut);

		this.bmp_tip2.alpha=0;
		egret.Tween.get(this.bmp_tip2).wait(1000+1000).to({alpha:1},600,egret.Ease.cubicInOut);

		var myThis=this;
		this.t1=setTimeout(function() {
			// myThis.particle.stop();
		},2000);


		this.mc.visible=false;
		this.mc.alpha=1;
		
		this.t2=setTimeout(function() {
			myThis.particle.start();
			myThis.particle.visible=true;
			myThis.mc.visible=true;
			myThis.mc.gotoAndPlay(1);
		}, (0));
	}
	
	private twAll;
    public Out():void
	{
		this.removeTween();
		this.particle.stop();
		if(this.t1)
		{
			clearTimeout(this.t1);
		}
		if(this.t2)
		{
			clearTimeout(this.t2)
		}
		egret.Tween.get(this.bmp_t0).to({ alpha: 0 }, 400);
		egret.Tween.get(this.bmp_t1).to({ alpha: 0 }, 400);
		egret.Tween.get(this.sp_mask).to({ scaleY: 0 }, 400);
		egret.Tween.get(this.bmp_t3).to({ alpha: 0 }, 400);
		egret.Tween.get(this.bmp_tip2).to({ alpha: 0 }, 400);
		
		egret.Tween.get(this.mc).to({ alpha: 0 }, 400);
		this.sp_mask.scaleY=0;
	}
	private removeTween():void
	{
		egret.Tween.removeTweens(this.bmp_t0);
		egret.Tween.removeTweens(this.bmp_t1);
		egret.Tween.removeTweens(this.bmp_t2);
		egret.Tween.removeTweens(this.bmp_t3);
		egret.Tween.removeTweens(this.sp_mask);
		egret.Tween.removeTweens(this.bmp_tip2);
		egret.Tween.removeTweens(this.mc);
	}
}